﻿// ===============================================================================
// XCI.Parent 西安交通信息WinForm开发框架 2019 版权所有
// ===============================================================================

using System;
using System.Diagnostics;
using System.Windows.Forms;
using XCI.Core;
using XCI.Windows;
using XCI.Helper;

namespace XCI.Sys.Forms
{
    public partial class FrmAbout : BaseForm
    {
        public FrmAbout()
        {
            InitializeComponent();
            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            labServer.Parent = labPhone.Parent = labCopyright.Parent = this;
            labWebSite.Parent = this;
            WinFormHelper.RegEscCloseForm(this);
        }

        private void AboutForm_Load(object sender, EventArgs e)
        {
            btnOK.Location = new System.Drawing.Point(-100, -100);
            this.Text = "关于 " + App.Setting.Name;
            this.labId.Text = $"标识：{App.Setting.Id}";
            this.labName.Text = $"名称：{App.Setting.Name}";
            this.labServer.Text = $"服务器：{App.Setting.Server.BaseUrl}";
            var fileBaseUrl = App.Setting.Server.BaseUrl;
            if (App.Setting.FileServer != null && !string.IsNullOrEmpty(App.Setting.FileServer.BaseUrl))
            {
                fileBaseUrl = App.Setting.FileServer.BaseUrl;
            }
            this.labFileServer.Text = $"文件服务器：{fileBaseUrl}";
        }

        private void SystemAboutForm_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void linkCompony_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                var txt = labWebSite.Text;
                var site = txt.Substring(txt.IndexOf("http", StringComparison.Ordinal));
                Process.Start(site);
            }
        }
    }
}